﻿//
// Created by gogoqiu on 2021/9/23.
//

#ifndef WXTEST_PREFERENCECORE_H
#define WXTEST_PREFERENCECORE_H
#include "vector"
#include "../PreferenceScreen.h"

#define KEY_MY_KEY1  "key_my_key1"
#define KEY_MY_KEY2  "key_my_key2"

class MyTagApp;
/*
 *
 * how to use the library
 * target_include_directories
 * add_subdirectory()
 * 实时性
 * 接口
 * 构建
 * 建立
 * 视图
 * 逻辑视图
 * PreferenceQueryLayer( PreferenceCore ): MyTagApp::mPreferenceCore
 *  PreferenceStorage
 *    Tag
 */
class PreferenceCore{
protected:
    MyTagApp * myTagApp;
    //
    std::vector<ViewList*> list;
    //filter to Preferences View
    vector<PreferenceView*> preferenceViews;
public:
    //list that contains the list for the view settings
    virtual void buildList() = 0;

    ViewList* getTitle( const wxString& key );

    //
    PreferenceView* getViewItem( PreferenceItem * item );

    /*
     * key
     */
    void buildViewList();

    wxString QueryValue( const wxString& key ) const;

    virtual void OnWithoutPreferenceTable( SqlitePreferenceStorage* ) = 0;

    virtual void OnPreferencePreLoad(SqlitePreferenceStorage* ) = 0;
    //
    SqlitePreferenceStorage *storage;
    //global variable or static unique variable, core data
    //static PreferenceCore* myPreHelper;
public:
    /*
    static PreferenceCore* getInstance( const wxString& TAG ){
        if( myPreHelper == nullptr ){
            myPreHelper = new PreferenceCore( TAG );
        }
        return myPreHelper;
    }*/

    /**
     * link
     */
    explicit PreferenceCore( MyTagApp * myTagApp );

    ~PreferenceCore();
    /*
    wxString get_my_key1();
    wxString get_my_key2();
    */
    int PutValue( const wxString& key, const wxString& value  ) const;

    vector<PreferenceView*> getPreferenceViews();

    void adapter();
};


#endif //WXTEST_PREFERENCECORE_H
